﻿using QuanLyGiaoVuDAL.ADOWrapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace QuanLyGiaoVuDAL.Repositories.DatabaseRepositories
{
    public class QuanLyQuyenTruyCapRepository : IQuanLyQuyenTruyCapRepository
    {
        public bool KiemTraQuyen(Guid maGiangVien, Guid maThuMuc)
        {
            var nguoiDungParameter = DBParameterFactory.Create("maNguoiDung", SqlDbType.UniqueIdentifier, maGiangVien);
            var maThuMucParameter = DBParameterFactory.Create("maThuMuc", SqlDbType.UniqueIdentifier, maThuMuc);
            var dbResult = StoreProcedureExecutor.ExecuteStoreProcedure("[dbo].[usp_QUYENTRUYCAPSelect]", nguoiDungParameter, maThuMucParameter);
            var giangvienTable = dbResult.Tables[0].Rows;
            return giangvienTable.Count > 0;
        }


        public void ThietLapQuyen(Guid maGiangVien, Guid maThuMuc)
        {
            var maGiangVienParameter = DBParameterFactory.Create("MaNguoiDung", SqlDbType.UniqueIdentifier, maGiangVien);
            var maThuMucParameter = DBParameterFactory.Create("MaThuMuc", SqlDbType.UniqueIdentifier, maThuMuc);
            var dbResult = StoreProcedureExecutor.ExecuteStoreProcedure("[dbo].[usp_QUYENTRUYCAPInsert]", maGiangVienParameter, maThuMucParameter);
        }
    }
}
